<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Divide numbers</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.gmp-com.html">gmp_com</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.gmp-div-qr.html">gmp_div_qr</a></div>
 <div class="up"><a href="ref.gmp.html">GMP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.gmp-div-q" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gmp_div_q</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5)</p><p class="refpurpose"><span class="refname">gmp_div_q</span> &mdash; <span class="dc-title">Divide numbers</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.gmp-div-q-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>gmp_div_q</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$a</code></span>
   , <span class="methodparam"><span class="type">resource</span> <code class="parameter">$b</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$round</code><span class="initializer"> = GMP_ROUND_ZERO</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Divides <em><code class="parameter">a</code></em> by <em><code class="parameter">b</code></em> and
   returns the integer result. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.gmp-div-q-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">a</code></em></dt>

     <dd>

      <p class="para">
       The number being divided.
      </p>
      <p class="para">可以是一个 GMP
数据 <span class="type"><span class="type resouce">resouce</span></span>，或一个可以转换为数值的字符串。</p> 
     </dd>

    
    
     <dt>
<em><code class="parameter">b</code></em></dt>

     <dd>

      <p class="para">
       The number that <em><code class="parameter">a</code></em> is being divided by.
      </p>
      <p class="para">可以是一个 GMP
数据 <span class="type"><span class="type resouce">resouce</span></span>，或一个可以转换为数值的字符串。</p> 
     </dd>

    
    
     <dt>
<em><code class="parameter">round</code></em></dt>

     <dd>

      <p class="para">
       The result rounding is defined by the
       <em><code class="parameter">round</code></em>, which can have the following
       values:
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          <strong><code>GMP_ROUND_ZERO</code></strong>: The result is truncated
          towards 0.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>GMP_ROUND_PLUSINF</code></strong>: The result is
          rounded towards <em>+infinity</em>.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>GMP_ROUND_MINUSINF</code></strong>: The result is
          rounded towards <em>-infinity</em>.
         </span>
        </li>
       </ul>
      </p>
      <p class="para">可以是一个 GMP
数据 <span class="type"><span class="type resouce">resouce</span></span>，或一个可以转换为数值的字符串。</p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.gmp-div-q-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   GMP 数值<span class="type"><span class="type 资源">资源</span></span>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.gmp-div-q-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3314">
    <p><strong>Example #1 <span class="function"><strong>gmp_div_q()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$div1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">gmp_div_q</span><span style="color: #007700">(</span><span style="color: #DD0000">"100"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"5"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">gmp_strval</span><span style="color: #007700">(</span><span style="color: #0000BB">$div1</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$div2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">gmp_div_q</span><span style="color: #007700">(</span><span style="color: #DD0000">"1"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"3"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">gmp_strval</span><span style="color: #007700">(</span><span style="color: #0000BB">$div2</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$div3&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">gmp_div_q</span><span style="color: #007700">(</span><span style="color: #DD0000">"1"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"3"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">GMP_ROUND_PLUSINF</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">gmp_strval</span><span style="color: #007700">(</span><span style="color: #0000BB">$div3</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$div4&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">gmp_div_q</span><span style="color: #007700">(</span><span style="color: #DD0000">"-1"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"4"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">GMP_ROUND_PLUSINF</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">gmp_strval</span><span style="color: #007700">(</span><span style="color: #0000BB">$div4</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$div5&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">gmp_div_q</span><span style="color: #007700">(</span><span style="color: #DD0000">"-1"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"4"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">GMP_ROUND_MINUSINF</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">gmp_strval</span><span style="color: #007700">(</span><span style="color: #0000BB">$div5</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
20
0
1
0
-1
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.gmp-div-q-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    This function can also be called as <span class="function"><a href="function.gmp-div.html" class="function">gmp_div()</a></span>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.gmp-div-q-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.gmp-div-r.html" class="function" rel="rdfs-seeAlso">gmp_div_r()</a> - Remainder of the division of numbers</span></li>
    <li class="member"><span class="function"><a href="function.gmp-div-qr.html" class="function" rel="rdfs-seeAlso">gmp_div_qr()</a> - Divide numbers and get quotient and remainder</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.gmp-com.html">gmp_com</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.gmp-div-qr.html">gmp_div_qr</a></div>
 <div class="up"><a href="ref.gmp.html">GMP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
